<?php
class adminMenu extends module {
	public $title = "Administrators menu";
	
	public function run() {
		$menu = $this->getMenuArray();
		$this->engine->xml->currentPageTitle = @$menu[$this->engine->primaryModule['module']];
		$i = 0;
		foreach ($menu as $k=>$v) {
			if ($this->user->can($k,'run')) {
				$this->xml->menuItem[$i] = _($v);
				$this->xml->menuItem[$i]['name'] = $k;
				if ($this->engine->primaryModule['module']==$k)
					$this->xml->menuItem[$i]['active'] = "1";
				$i++;
			}
		}
	}
	
	private function getMenuArray() {
		$menu = array();
		foreach (explode(';',ADMIN_MENU) as $menuEl) {
			if ($menuEl) {
				list($m,$t) = explode("=>", $menuEl);
				if ($m AND $t) {
					$menu[trim($m)] = trim($t);
				}
			}
		}
		return $menu;
	}
}
?>